/**
 * 
 */
package com.delta.rafg.core.database.impl;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Date;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.RowIdLifetime;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.parser.CCJSqlParserManager;

import com.delta.rafg.core.database.GenericDataSourceTables;
import com.delta.rafg.core.database.IGenericDataSource;
import com.delta.rafg.core.database.impl.util.DatabaseUtils;
import com.delta.rafg.core.database.impl.util.JSqlVisitor;
import com.delta.rafg.core.log.RAFGLogger;

/**
 * @author D9127520
 *
 */
public abstract class AGenericDataSource implements IGenericDataSource {

	protected String PROP_IDENTIFIER = "soa_ref_data";
	protected String SCHEMA_NAME = GenericDataSourceTables.SCHEMA_NAME;;
	protected List<String> TABLE_NAMES = new ArrayList<String>();	
	protected Map<String,List<GenericDataSourceColumnInfo>> COLUMNS = new HashMap<String,List<GenericDataSourceColumnInfo>>();
	protected Map<String,List<String>> COLUMN_INDEXES = new HashMap<String,List<String>>();
	protected java.sql.Connection sqlConnection = new GenericSqlConnection();
	
	/* (non-Javadoc)
	 * @see com.delta.rafg.core.database.IGenericDataSource#getPropertyIdentifier()
	 */
	@Override
	public String getPropertyIdentifier() {
		return PROP_IDENTIFIER;
	}

	/* (non-Javadoc)
	 * @see com.delta.rafg.core.database.IGenericDataSource#getSchemaName()
	 */
	@Override
	public String getSchemaName() {
		return SCHEMA_NAME;
	}

	/* (non-Javadoc)
	 * @see com.delta.rafg.core.database.IGenericDataSource#getTableNames()
	 */
	@Override
	public List<String> getTableNames() {
		return TABLE_NAMES;
	}

	/* (non-Javadoc)
	 * @see com.delta.rafg.core.database.IGenericDataSource#getColumns()
	 */
	@Override
	public List<GenericDataSourceColumnInfo> getColumns(String tableName) {
		return COLUMNS.get(DatabaseUtils.getTableName(tableName));
	}

	/* (non-Javadoc)
	 * @see com.delta.rafg.core.database.IGenericDataSource#getIndexColumns()
	 */
	@Override
	public List<String> getIndexColumns(String tableName) {
		return COLUMN_INDEXES.get(DatabaseUtils.getTableName(tableName));
	}

	/* (non-Javadoc)
	 * @see com.delta.rafg.core.database.IGenericDataSource#getSqlConnection()
	 */
	public Connection getSqlConnection() {
		return sqlConnection;
	}
	
	public String[] getChangedTables() {
		if (isSynchronizable()) {
			if(TABLE_NAMES.size()>0) {
				List<String> fullyQualifiedTableNames = new ArrayList<String>();
				for (String table : TABLE_NAMES) {
					fullyQualifiedTableNames.add(getSchemaName() + "." + table);
				}
				return fullyQualifiedTableNames.toArray(new String[fullyQualifiedTableNames.size()]);
			} else {
				return null;
			}
		} else {
			return null;
		}
	}
	
	public static class GenericDataSourceColumnInfo implements Cloneable {
		private String columnName;
		private int columnType;
		private int columnLen;
		private int columnScale = 0;
		private Object columnData = null;
		private boolean isNullable = true;
		
		/**
		 * @param columnName
		 * @param columnType
		 * @param columnLen
		 */
		public GenericDataSourceColumnInfo(String columnName, int columnType, int columnLen) {
			this.columnName = columnName;
			this.columnType = columnType;
			this.columnLen = columnLen;
		}

		public GenericDataSourceColumnInfo(String columnName, Object columnData) {
			this.columnName = columnName;
			this.columnType = java.sql.Types.VARCHAR;
			this.columnLen = 255;
			this.columnData = columnData;
		}

		/**
		 * @param columnName
		 * @param columnType
		 * @param columnLen
		 * @param columnData
		 *
		public GenericDataSourceColumnInfo(String columnName, int columnType, int columnLen, Object columnData) {
			this.columnName = columnName;
			this.columnType = columnType;
			this.columnLen = columnLen;
			this.columnData = columnData;
		}
*/
		/**
		 * @param columnName
		 * @param columnType
		 * @param columnLen
		 * @param columnScale
		 * @param isNullable
		 */
		public GenericDataSourceColumnInfo(String columnName, int columnType, int columnLen, int columnScale, boolean isNullable) {
			this.columnName = columnName;
			this.columnType = columnType;
			this.columnLen = columnLen;
			this.columnScale = columnScale;
			this.isNullable = isNullable;
		}

		/**
		 * @param columnName
		 * @param columnType
		 * @param columnLen
		 * @param columnScale
		 * @param isNullable
		 * @param columnData
		 */
		public GenericDataSourceColumnInfo(String columnName, int columnType, int columnLen, int columnScale, boolean isNullable, Object columnData) {
			this.columnName = columnName;
			this.columnType = columnType;
			this.columnLen = columnLen;
			this.columnScale = columnScale;
			this.isNullable = isNullable;
			this.columnData = columnData;
		}

		public String getColumnName() {
			return columnName;
		}

		public int getColumnType() {
			return columnType;
		}

		public int getColumnLen() {
			return columnLen;
		}

		public int getColumnScale() {
			return columnScale;
		}

		public boolean isNullable() {
			return isNullable;
		}

		public Object getColumnData() {
			return columnData;
		}

		public void setColumnData(Object columnData) {
			this.columnData = columnData;
		}
		
		@Override
		public GenericDataSourceColumnInfo clone() {
			GenericDataSourceColumnInfo clonedColInfo = new GenericDataSourceColumnInfo(columnName, columnType, columnLen, columnScale,isNullable);
			clonedColInfo.setColumnData(columnData);
			return clonedColInfo;
		}
		
		@Override
		public String toString() {
			StringBuilder sb = new StringBuilder();
			sb.append(columnName);
			sb.append("[");
			sb.append(DatabaseUtils.getJdbcTypeName(columnType));
			sb.append(":");
			sb.append(columnLen);
			if (columnScale != 0) {
				sb.append(".");
				sb.append(columnScale);
			}
			sb.append("]=");
			sb.append(columnData);
			return sb.toString();
		}

	}
	
	public class GenericSqlConnection implements java.sql.Connection {

		@Override
		public <T> T unwrap(Class<T> iface) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public boolean isWrapperFor(Class<?> iface) throws SQLException {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public void clearWarnings() throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void close() throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void commit() throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public Statement createStatement() throws SQLException {
			GenericStatement stmt = new GenericStatement();
			return stmt;
		}

		@Override
		public Statement createStatement(int resultSetType,
				int resultSetConcurrency) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Statement createStatement(int resultSetType,
				int resultSetConcurrency, int resultSetHoldability)
				throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public boolean getAutoCommit() throws SQLException {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public String getCatalog() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public int getHoldability() throws SQLException {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public DatabaseMetaData getMetaData() throws SQLException {
			return new GenericMetaData();
		}

		@Override
		public int getTransactionIsolation() throws SQLException {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public Map<String, Class<?>> getTypeMap() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public SQLWarning getWarnings() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public boolean isClosed() throws SQLException {
			return false;
		}

		@Override
		public boolean isReadOnly() throws SQLException {
			return false;
		}

		@Override
		public String nativeSQL(String sql) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public CallableStatement prepareCall(String sql) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public CallableStatement prepareCall(String sql, int resultSetType,
				int resultSetConcurrency) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public CallableStatement prepareCall(String sql, int resultSetType,
				int resultSetConcurrency, int resultSetHoldability)
				throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public PreparedStatement prepareStatement(String sql)
				throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				int autoGeneratedKeys) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				int[] columnIndexes) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				int resultSetType, int resultSetConcurrency)
				throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				int resultSetType, int resultSetConcurrency,
				int resultSetHoldability) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				String[] columnNames) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public void releaseSavepoint(Savepoint savepoint) throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void rollback() throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void rollback(Savepoint savepoint) throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setAutoCommit(boolean autoCommit) throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setCatalog(String catalog) throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setHoldability(int holdability) throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setReadOnly(boolean readOnly) throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public Savepoint setSavepoint() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Savepoint setSavepoint(String name) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public void setTransactionIsolation(int level) throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public Clob createClob() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Blob createBlob() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public NClob createNClob() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public SQLXML createSQLXML() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public boolean isValid(int timeout) throws SQLException {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public void setClientInfo(String name, String value)
				throws SQLClientInfoException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setClientInfo(Properties properties)
				throws SQLClientInfoException {
			// TODO Auto-generated method stub
			
		}

		@Override
		public String getClientInfo(String name) throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Properties getClientInfo() throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Array createArrayOf(String typeName, Object[] elements)
				throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Struct createStruct(String typeName, Object[] attributes)
				throws SQLException {
			// TODO Auto-generated method stub
			return null;
		}
		
		protected class GenericMetaData implements DatabaseMetaData {

			@Override
			public <T> T unwrap(Class<T> iface) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public boolean isWrapperFor(Class<?> iface) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean allProceduresAreCallable() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean allTablesAreSelectable() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean dataDefinitionCausesTransactionCommit()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean dataDefinitionIgnoredInTransactions()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean deletesAreDetected(int type) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public ResultSet getAttributes(String catalog,
					String schemaPattern, String typeNamePattern,
					String attributeNamePattern) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getBestRowIdentifier(String catalog,
					String schema, String table, int scope, boolean nullable)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getCatalogs() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getCatalogSeparator() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getCatalogTerm() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getColumnPrivileges(String catalog, String schema,
					String table, String columnNamePattern) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getColumns(String catalog, String schemaPattern,
					String tableNamePattern, String columnNamePattern)
					throws SQLException {
				GenericResultSet rs = new GenericResultSet();
				for(GenericDataSourceColumnInfo column : AGenericDataSource.this.getColumns(tableNamePattern)) {
					ArrayList<GenericDataSourceColumnInfo> row = new ArrayList<GenericDataSourceColumnInfo>();
					row.add(new GenericDataSourceColumnInfo("COLUMN_NAME", column.getColumnName()));
		            row.add(new GenericDataSourceColumnInfo("COLUMN_SIZE", column.getColumnLen()));
		            row.add(new GenericDataSourceColumnInfo("DATA_TYPE", column.getColumnType()));
		            row.add(new GenericDataSourceColumnInfo("TYPE_NAME", DatabaseUtils.getJdbcTypeName(column.getColumnType())));
					rs.addRow(row);
				}
				return rs;
			}

			@Override
			public Connection getConnection() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getCrossReference(String primaryCatalog,
					String primarySchema, String primaryTable,
					String foreignCatalog, String foreignSchema,
					String foreignTable) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getDatabaseMajorVersion() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getDatabaseMinorVersion() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public String getDatabaseProductName() throws SQLException {
				return "Generic DataSource";
			}

			@Override
			public String getDatabaseProductVersion() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getDefaultTransactionIsolation() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getDriverMajorVersion() {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getDriverMinorVersion() {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public String getDriverName() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getDriverVersion() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getExportedKeys(String catalog, String schema,
					String table) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getExtraNameCharacters() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getIdentifierQuoteString() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getImportedKeys(String catalog, String schema,
					String table) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getIndexInfo(String catalog, String schema,
					String table, boolean unique, boolean approximate)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getJDBCMajorVersion() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getJDBCMinorVersion() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxBinaryLiteralLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxCatalogNameLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxCharLiteralLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxColumnNameLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxColumnsInGroupBy() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxColumnsInIndex() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxColumnsInOrderBy() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxColumnsInSelect() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxColumnsInTable() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxConnections() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxCursorNameLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxIndexLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxProcedureNameLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxRowSize() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxSchemaNameLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxStatementLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxStatements() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxTableNameLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxTablesInSelect() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxUserNameLength() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public String getNumericFunctions() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getPrimaryKeys(String catalog, String schema,
					String table) throws SQLException {
				GenericResultSet rs = new GenericResultSet();
				List<String> indexCols = AGenericDataSource.this.getIndexColumns(table); 
				if (indexCols != null) {
					for(String column : indexCols) {
						ArrayList<GenericDataSourceColumnInfo> row = new ArrayList<GenericDataSourceColumnInfo>();
						row.add( new GenericDataSourceColumnInfo("COLUMN_NAME", column));
						rs.addRow(row);
					}
				}
				return rs;
			}

			@Override
			public ResultSet getProcedureColumns(String catalog,
					String schemaPattern, String procedureNamePattern,
					String columnNamePattern) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getProcedures(String catalog,
					String schemaPattern, String procedureNamePattern)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getProcedureTerm() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getResultSetHoldability() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public ResultSet getSchemas() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getSchemaTerm() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getSearchStringEscape() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getSQLKeywords() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getSQLStateType() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public String getStringFunctions() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getSuperTables(String catalog,
					String schemaPattern, String tableNamePattern)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getSuperTypes(String catalog,
					String schemaPattern, String typeNamePattern)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getSystemFunctions() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getTablePrivileges(String catalog,
					String schemaPattern, String tableNamePattern)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getTables(String catalog, String schemaPattern,
					String tableNamePattern, String[] types)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getTableTypes() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getTimeDateFunctions() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getTypeInfo() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getUDTs(String catalog, String schemaPattern,
					String typeNamePattern, int[] types) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getURL() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getUserName() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getVersionColumns(String catalog, String schema,
					String table) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public boolean insertsAreDetected(int type) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean isCatalogAtStart() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean isReadOnly() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean locatorsUpdateCopy() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean nullPlusNonNullIsNull() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean nullsAreSortedAtEnd() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean nullsAreSortedAtStart() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean nullsAreSortedHigh() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean nullsAreSortedLow() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean othersDeletesAreVisible(int type)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean othersInsertsAreVisible(int type)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean othersUpdatesAreVisible(int type)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean ownDeletesAreVisible(int type) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean ownInsertsAreVisible(int type) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean ownUpdatesAreVisible(int type) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean storesLowerCaseIdentifiers() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean storesLowerCaseQuotedIdentifiers()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean storesMixedCaseIdentifiers() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean storesMixedCaseQuotedIdentifiers()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean storesUpperCaseIdentifiers() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean storesUpperCaseQuotedIdentifiers()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsAlterTableWithAddColumn()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsAlterTableWithDropColumn()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsANSI92EntryLevelSQL() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsANSI92FullSQL() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsANSI92IntermediateSQL() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsBatchUpdates() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsCatalogsInDataManipulation()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsCatalogsInIndexDefinitions()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsCatalogsInPrivilegeDefinitions()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsCatalogsInProcedureCalls()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsCatalogsInTableDefinitions()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsColumnAliasing() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsConvert() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsConvert(int fromType, int toType)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsCoreSQLGrammar() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsCorrelatedSubqueries() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsDataDefinitionAndDataManipulationTransactions()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsDataManipulationTransactionsOnly()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsDifferentTableCorrelationNames()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsExpressionsInOrderBy() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsExtendedSQLGrammar() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsFullOuterJoins() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsGetGeneratedKeys() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsGroupBy() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsGroupByBeyondSelect() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsGroupByUnrelated() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsIntegrityEnhancementFacility()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsLikeEscapeClause() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsLimitedOuterJoins() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsMinimumSQLGrammar() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsMixedCaseIdentifiers() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsMixedCaseQuotedIdentifiers()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsMultipleOpenResults() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsMultipleResultSets() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsMultipleTransactions() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsNamedParameters() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsNonNullableColumns() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsOpenCursorsAcrossCommit()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsOpenCursorsAcrossRollback()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsOpenStatementsAcrossCommit()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsOpenStatementsAcrossRollback()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsOrderByUnrelated() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsOuterJoins() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsPositionedDelete() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsPositionedUpdate() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsResultSetConcurrency(int type,
					int concurrency) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsResultSetHoldability(int holdability)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsResultSetType(int type) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSavepoints() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSchemasInDataManipulation()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSchemasInIndexDefinitions()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSchemasInPrivilegeDefinitions()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSchemasInProcedureCalls()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSchemasInTableDefinitions()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSelectForUpdate() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsStatementPooling() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsStoredProcedures() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSubqueriesInComparisons()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSubqueriesInExists() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSubqueriesInIns() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsSubqueriesInQuantifieds()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsTableCorrelationNames() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsTransactionIsolationLevel(int level)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsTransactions() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsUnion() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean supportsUnionAll() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean updatesAreDetected(int type) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean usesLocalFilePerTable() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean usesLocalFiles() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public RowIdLifetime getRowIdLifetime() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getSchemas(String catalog, String schemaPattern)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public boolean supportsStoredFunctionsUsingCallSyntax()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean autoCommitFailureClosesAllResultSets()
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public ResultSet getClientInfoProperties() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getFunctions(String catalog, String schemaPattern,
					String functionNamePattern) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet getFunctionColumns(String catalog,
					String schemaPattern, String functionNamePattern,
					String columnNamePattern) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}
			
		}
		
		protected class GenericResultSet implements java.sql.ResultSet {
			
			private List<List<GenericDataSourceColumnInfo>> rows = new ArrayList<List<GenericDataSourceColumnInfo>>();
			private int rowPtr = -1;
			private List<GenericDataSourceColumnInfo> cols = new ArrayList<GenericDataSourceColumnInfo>();
			private Map<Integer, Integer> colIndexMap = new HashMap<Integer, Integer>();

			synchronized void initColumns(List<GenericDataSourceColumnInfo> cols) {
				this.cols = cols;
			}
			
			private synchronized int getColIndex(int col) {
				Integer retIndex = colIndexMap.get(col);
				if (retIndex == null) {
					//find which index this mapped column equates to.  There must be at least one row to be able to look it up.
					if (rows.size() > 0) {
						for (int i = 0; i < cols.size(); i++) {
							GenericDataSourceColumnInfo colInfo = rows.get(0).get(i);
							if (colInfo.getColumnName().equalsIgnoreCase(cols.get(col).getColumnName())) {
								retIndex = i;
								colIndexMap.put(col, retIndex);
								break;
							}
						}
					}
				}
				return retIndex;
			}
			
			
			/**
			 * @param row 
			 */
			synchronized void addRow(List<GenericDataSourceColumnInfo> row) {
				rows.add(row);
			}
			
			@Override
			public <T> T unwrap(Class<T> iface) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public boolean isWrapperFor(Class<?> iface) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean absolute(int row) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public void afterLast() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void beforeFirst() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void cancelRowUpdates() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void clearWarnings() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void close() throws SQLException {
				rowPtr = -2;
				rows = null;
			}

			@Override
			public void deleteRow() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public int findColumn(String columnName) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public boolean first() throws SQLException {
				rowPtr = -1;
				return true;
			}

			@Override
			public Array getArray(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Array getArray(String colName) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public InputStream getAsciiStream(int columnIndex)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public InputStream getAsciiStream(String columnName)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public BigDecimal getBigDecimal(int columnIndex)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public BigDecimal getBigDecimal(int columnIndex, int scale)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public BigDecimal getBigDecimal(String columnName)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public BigDecimal getBigDecimal(String columnName, int scale)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public InputStream getBinaryStream(int columnIndex)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public InputStream getBinaryStream(String columnName)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Blob getBlob(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Blob getBlob(String columnName) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public boolean getBoolean(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean getBoolean(String columnName) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public byte getByte(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public byte getByte(String columnName) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public byte[] getBytes(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public byte[] getBytes(String columnName) throws SQLException {
			 byte[] bytes = null;
			  ByteArrayOutputStream bos = new ByteArrayOutputStream();
			  try {
			    ObjectOutputStream oos = new ObjectOutputStream(bos); 
			    oos.writeObject(getObject(columnName));
			    oos.flush(); 
			    oos.close(); 
			    bos.close();
			    bytes = bos.toByteArray ();
			  }
			  catch (IOException ex) {
				  throw new SQLException(ex);
			  }
			  return bytes;
			}

			@Override
			public Reader getCharacterStream(int columnIndex)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Reader getCharacterStream(String columnName)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Clob getClob(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Clob getClob(String colName) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getConcurrency() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public String getCursorName() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Date getDate(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Date getDate(int columnIndex, Calendar cal)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Date getDate(String columnName) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Date getDate(String columnName, Calendar cal)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public double getDouble(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public double getDouble(String columnName) throws SQLException {
				return ((Double)(getObject(columnName)));
			}

			@Override
			public int getFetchDirection() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getFetchSize() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public float getFloat(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public float getFloat(String columnName) throws SQLException {
				return ((Float)(getObject(columnName)));
			}

			@Override
			public int getInt(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getInt(String columnName) throws SQLException {
				return ((Integer)(getObject(columnName)));
			}

			@Override
			public long getLong(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public long getLong(String columnName) throws SQLException {
				return ((Long)(getObject(columnName)));
			}

			@Override
			public ResultSetMetaData getMetaData() throws SQLException {
				ResultSetMetaData rs = new GenericResultSetMetaData();
				return rs;
			}

			@Override
			public Object getObject(int columnIndex) throws SQLException {
				List<GenericDataSourceColumnInfo> row = rows.get(rowPtr);
				if (columnIndex > 0 && columnIndex <= row.size()) {
					GenericDataSourceColumnInfo entry = row.get(getColIndex(columnIndex-1));
					return entry.getColumnData();
				}
				return null;
			}

			@Override
			public Object getObject(int columnIndex, Map<String, Class<?>> map)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Object getObject(String columnName) throws SQLException {
				List<GenericDataSourceColumnInfo> row = rows.get(rowPtr);
				for(GenericDataSourceColumnInfo entry : row) {
					if(entry.getColumnName().equalsIgnoreCase(columnName)) {
						return entry.getColumnData();
					}
				}
				return null;
			}

			@Override
			public Object getObject(String columnName, Map<String, Class<?>> map)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Ref getRef(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Ref getRef(String colName) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getRow() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public short getShort(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public short getShort(String columnName) throws SQLException {
				return ((Short)(getObject(columnName)));
			}

			@Override
			public Statement getStatement() throws SQLException {
				return new GenericStatement();
			}

			@Override
			public String getString(int columnIndex) throws SQLException {
				return (String) getObject(columnIndex);
			}

			@Override
			public String getString(String columnName) throws SQLException {
				return (String) getObject(columnName);
			}

			@Override
			public Time getTime(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Time getTime(int columnIndex, Calendar cal)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Time getTime(String columnName) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Time getTime(String columnName, Calendar cal)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Timestamp getTimestamp(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Timestamp getTimestamp(int columnIndex, Calendar cal)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Timestamp getTimestamp(String columnName)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Timestamp getTimestamp(String columnName, Calendar cal)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getType() throws SQLException {
				return ResultSet.TYPE_SCROLL_INSENSITIVE;
			}

			@Override
			public InputStream getUnicodeStream(int columnIndex)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public InputStream getUnicodeStream(String columnName)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public URL getURL(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public URL getURL(String columnName) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public SQLWarning getWarnings() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void insertRow() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public boolean isAfterLast() throws SQLException {
				if (rowPtr >= rows.size()) {
					return true;
				} else {
					return false;
				}
			}

			@Override
			public boolean isBeforeFirst() throws SQLException {
				if (rowPtr == -1) {
					return true;
				} else {
					return false;
				}
			}

			@Override
			public boolean isFirst() throws SQLException {
				if (rowPtr == 0) {
					return true;
				} else {
					return false;
				}
			}

			@Override
			public boolean isLast() throws SQLException {
				if (rowPtr == rows.size()-1) {
					return true;
				} else {
					return false;
				}
			}

			@Override
			public boolean last() throws SQLException {
				if (rows.size() > 0) {
					rowPtr = rows.size()-1;
					return true;
				} else {
					return false;
				}
			}

			@Override
			public void moveToCurrentRow() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void moveToInsertRow() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public boolean next() throws SQLException {
				rowPtr++;
				if (rowPtr < rows.size()) {
					return true;
				} else {
					return false;
				}
			}

			@Override
			public boolean previous() throws SQLException {
				rowPtr--;
				if (rowPtr >= 0) {
					return true;
				} else {
					return false;
				}
			}

			@Override
			public void refreshRow() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public boolean relative(int rows) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean rowDeleted() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean rowInserted() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean rowUpdated() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public void setFetchDirection(int direction) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void setFetchSize(int rows) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateArray(int columnIndex, Array x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateArray(String columnName, Array x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateAsciiStream(int columnIndex, InputStream x,
					int length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateAsciiStream(String columnName, InputStream x,
					int length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBigDecimal(int columnIndex, BigDecimal x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBigDecimal(String columnName, BigDecimal x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBinaryStream(int columnIndex, InputStream x,
					int length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBinaryStream(String columnName, InputStream x,
					int length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBlob(int columnIndex, Blob x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBlob(String columnName, Blob x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBoolean(int columnIndex, boolean x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBoolean(String columnName, boolean x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateByte(int columnIndex, byte x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateByte(String columnName, byte x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBytes(int columnIndex, byte[] x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBytes(String columnName, byte[] x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateCharacterStream(int columnIndex, Reader x,
					int length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateCharacterStream(String columnName, Reader reader,
					int length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateClob(int columnIndex, Clob x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateClob(String columnName, Clob x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateDate(int columnIndex, Date x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateDate(String columnName, Date x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateDouble(int columnIndex, double x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateDouble(String columnName, double x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateFloat(int columnIndex, float x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateFloat(String columnName, float x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateInt(int columnIndex, int x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateInt(String columnName, int x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateLong(int columnIndex, long x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateLong(String columnName, long x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNull(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNull(String columnName) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateObject(int columnIndex, Object x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateObject(int columnIndex, Object x, int scale)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateObject(String columnName, Object x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateObject(String columnName, Object x, int scale)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateRef(int columnIndex, Ref x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateRef(String columnName, Ref x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateRow() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateShort(int columnIndex, short x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateShort(String columnName, short x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateString(int columnIndex, String x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateString(String columnName, String x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateTime(int columnIndex, Time x) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateTime(String columnName, Time x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateTimestamp(int columnIndex, Timestamp x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateTimestamp(String columnName, Timestamp x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public boolean wasNull() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public RowId getRowId(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public RowId getRowId(String columnLabel) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void updateRowId(int columnIndex, RowId x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateRowId(String columnLabel, RowId x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public int getHoldability() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public boolean isClosed() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public void updateNString(int columnIndex, String nString)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNString(String columnLabel, String nString)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNClob(int columnIndex, NClob nClob)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNClob(String columnLabel, NClob nClob)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public NClob getNClob(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public NClob getNClob(String columnLabel) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public SQLXML getSQLXML(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public SQLXML getSQLXML(String columnLabel) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void updateSQLXML(int columnIndex, SQLXML xmlObject)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateSQLXML(String columnLabel, SQLXML xmlObject)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public String getNString(int columnIndex) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public String getNString(String columnLabel) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Reader getNCharacterStream(int columnIndex)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Reader getNCharacterStream(String columnLabel)
					throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void updateNCharacterStream(int columnIndex, Reader x,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNCharacterStream(String columnLabel,
					Reader reader, long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateAsciiStream(int columnIndex, InputStream x,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBinaryStream(int columnIndex, InputStream x,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateCharacterStream(int columnIndex, Reader x,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateAsciiStream(String columnLabel, InputStream x,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBinaryStream(String columnLabel, InputStream x,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateCharacterStream(String columnLabel,
					Reader reader, long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBlob(int columnIndex, InputStream inputStream,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBlob(String columnLabel, InputStream inputStream,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateClob(int columnIndex, Reader reader, long length)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateClob(String columnLabel, Reader reader,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNClob(int columnIndex, Reader reader, long length)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNClob(String columnLabel, Reader reader,
					long length) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNCharacterStream(int columnIndex, Reader x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNCharacterStream(String columnLabel, Reader reader)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateAsciiStream(int columnIndex, InputStream x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBinaryStream(int columnIndex, InputStream x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateCharacterStream(int columnIndex, Reader x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateAsciiStream(String columnLabel, InputStream x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBinaryStream(String columnLabel, InputStream x)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateCharacterStream(String columnLabel, Reader reader)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBlob(int columnIndex, InputStream inputStream)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateBlob(String columnLabel, InputStream inputStream)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateClob(int columnIndex, Reader reader)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateClob(String columnLabel, Reader reader)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNClob(int columnIndex, Reader reader)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void updateNClob(String columnLabel, Reader reader)
					throws SQLException {
				// TODO Auto-generated method stub
				
			}
			
			public class GenericResultSetMetaData implements java.sql.ResultSetMetaData {

				@Override
				public <T> T unwrap(Class<T> iface) throws SQLException {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public boolean isWrapperFor(Class<?> iface) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}

				@Override
				public String getCatalogName(int column) throws SQLException {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public String getColumnClassName(int column) throws SQLException {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public int getColumnCount() throws SQLException {
					return cols.size();
				}

				@Override
				public int getColumnDisplaySize(int column) throws SQLException {
					if (column > 0 && column <= cols.size()) {
						return cols.get(column-1).getColumnLen();
					} else {
						throw new SQLException("Invalid column index");
					}
				}

				@Override
				public String getColumnLabel(int column) throws SQLException {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public String getColumnName(int column) throws SQLException {
					if (0 < column && column <= cols.size()) {
						return cols.get(column-1).getColumnName();
					} else {
						return null;
					}
					
				}

				@Override
				public int getColumnType(int column) throws SQLException {
					if (column > 0 && column <= cols.size()) {
						return cols.get(column-1).getColumnType();
					} else {
						throw new SQLException("Invalid column index");
					}
					
				}

				@Override
				public String getColumnTypeName(int column) throws SQLException {
					if (column > 0 && column <= cols.size()) {
						return DatabaseUtils.getJdbcTypeName(cols.get(column-1).getColumnType());
					} else {
						throw new SQLException("Invalid column index");
					}
				}

				@Override
				public int getPrecision(int column) throws SQLException {
					// TODO Auto-generated method stub
					return 0;
				}

				@Override
				public int getScale(int column) throws SQLException {
					if (column > 0 && column <= cols.size()) {
						return cols.get(column-1).getColumnScale();
					} else {
						throw new SQLException("Invalid column index");
					}
				}

				@Override
				public String getSchemaName(int column) throws SQLException {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public String getTableName(int column) throws SQLException {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public boolean isAutoIncrement(int column) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}

				@Override
				public boolean isCaseSensitive(int column) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}

				@Override
				public boolean isCurrency(int column) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}

				@Override
				public boolean isDefinitelyWritable(int column) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}

				@Override
				public int isNullable(int column) throws SQLException {
					if (column > 0 && column <= cols.size()) {
						if (cols.get(column-1).isNullable()) return ResultSetMetaData.columnNullable;
						else return ResultSetMetaData.columnNoNulls;
					} else {
						throw new SQLException("Invalid column index");
					}
				}

				@Override
				public boolean isReadOnly(int column) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}

				@Override
				public boolean isSearchable(int column) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}

				@Override
				public boolean isSigned(int column) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}

				@Override
				public boolean isWritable(int column) throws SQLException {
					// TODO Auto-generated method stub
					return false;
				}
				
			}
		}
		
		public class GenericStatement implements java.sql.Statement {

			List<GenericResultSet> resultSets = new ArrayList<GenericResultSet>();
			int curResultSet = 0;
			
			@Override
			public <T> T unwrap(Class<T> iface) throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public boolean isWrapperFor(Class<?> iface) throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public void addBatch(String sql) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void cancel() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void clearBatch() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void clearWarnings() throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void close() throws SQLException {
				resultSets.clear();
			}

			@Override
			public boolean execute(String sql) throws SQLException {
				List<List<GenericDataSourceColumnInfo>> retRows = null;
				CCJSqlParserManager pm = new CCJSqlParserManager();
				net.sf.jsqlparser.statement.Statement statement;
				List<String> cols = null;
				String tableName = null;
				try {
					statement = pm.parse(new StringReader(sql));
					JSqlVisitor visitor = new JSqlVisitor();
					statement.accept(visitor);
					if(visitor.getTables().size()>0) {
						tableName = visitor.getTables().get(0);
						if (visitor.getColumns().size()>0) {
							cols = visitor.getColumns();
						} else if (visitor.isAllColumns()) {
							cols = new ArrayList<String>();
							for (GenericDataSourceColumnInfo colInfo : AGenericDataSource.this.getColumns(tableName)) {
								cols.add(colInfo.getColumnName());
							}
						}
						retRows = AGenericDataSource.this.getColumnData(tableName, cols);
						if (retRows != null) {
							List<String> orderBy = visitor.getOrderBy();
							if(orderBy != null && !orderBy.isEmpty()) {
								sortRows(retRows, orderBy);
							} else {
								sortRows(retRows, cols);							
							}
						}
					}
				} catch (JSQLParserException e) {
					e.printStackTrace();
				}
				GenericResultSet rs = new GenericResultSet();
				rs.initColumns(getColumnQueryDetails(tableName, cols));
				if(retRows != null) {
					for (List<GenericDataSourceColumnInfo> row : retRows) {
						rs.addRow(row);
					}
				}
				
				resultSets.clear();
				resultSets.add(rs);
				
				return true;			}

			private void sortRows(
					List<List<GenericDataSourceColumnInfo>> retRows,
					List<String> colOrder) {

				java.util.Comparator<List<GenericDataSourceColumnInfo>> comp = new RowComparable(colOrder);
				Collections.sort(retRows, comp);
			}
			
			private class RowComparable implements java.util.Comparator<List<GenericDataSourceColumnInfo>>{
				private List<String> colOrder;
				private Map<String,Integer> colOrderMapLeft = null;
				private Map<String,Integer> colOrderMapRight = null;
				
				public RowComparable(List<String> colOrder) {
					this.colOrder = colOrder;
				}
				
				private synchronized void mapLeftCols(List<GenericDataSourceColumnInfo> o) {
					if (colOrderMapLeft == null) {
						colOrderMapLeft = mapCols(o);
					}
				}

				private synchronized void mapRightCols(List<GenericDataSourceColumnInfo> o) {
					if (colOrderMapRight == null) {
						colOrderMapRight = mapCols(o);
					}
				}
				
				private Map<String,Integer> mapCols(List<GenericDataSourceColumnInfo> o) {
					int size = o.size();
					Map<String,Integer> retMap = new HashMap<String,Integer>(size);
					for (String col : colOrder) {
						for (int i = 0; i < size; i++) {
							if (o.get(i).getColumnName().equalsIgnoreCase(col)) {
								retMap.put(col, i);
								break;
							}
						}
					}
					return retMap;
				}

			    @Override
			    public int compare(List<GenericDataSourceColumnInfo> o1, List<GenericDataSourceColumnInfo> o2) {
			    	if (o1 == null) {
			    		if (o2 == null) return 0;
			    		else return -1;
			    	}
			    	if (o2 == null) return 1;
			    	
			    	if (colOrderMapLeft == null) {
			    		mapLeftCols(o1);
			    	}
			    	if (colOrderMapRight == null) {
			    		mapRightCols(o2);
			    	}
			    	
			    	for (String col : colOrder) {
			    		GenericDataSourceColumnInfo o1ColInfo = o1.get(colOrderMapLeft.get(col));
			    		GenericDataSourceColumnInfo o2ColInfo = o2.get(colOrderMapRight.get(col));
			    		Object o1dat = o1ColInfo.getColumnData();
   						Object o2dat = o2ColInfo.getColumnData();
   						if (o1dat == null) {
   							if (o2dat == null) {
   								break;
   							} else {
   								return 0;
   							}
   						}
						if (o2dat == null) {
							return 1;
						}
   						if (o1dat.getClass() == o2dat.getClass()) {
	    					int colCompResult = compareCols(o1dat, o2dat);
	    					if (colCompResult != 0) return colCompResult;
   						} else {
   							RAFGLogger.error("Failure comparing " + o1ColInfo.getColumnName() + " to " + o2ColInfo.getColumnName() 
   									+ "; datatypes not the same. " + o1dat.getClass().getName() + " vs " + o2dat.getClass().getName(), null);
   							//not same type, just return 0, I cant compare these.
   							return 0;
   						}
			    	}
			        return 0;
			    }
			    
			    private int compareCols(Object o1, Object o2) {
			    	if (o1 instanceof String) {
			    		return ((String) o1).compareTo((String) o2);
			    	} else {
							RAFGLogger.error("Don't know how to compare " + o1.getClass().getName() + " to " + o2.getClass().getName(), null);
			    	}
			    	
			    	return o1.equals(o2) ? 0 : -1;
			    }
			}

			@Override
			public boolean execute(String sql, int autoGeneratedKeys)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean execute(String sql, int[] columnIndexes)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public boolean execute(String sql, String[] columnNames)
					throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public int[] executeBatch() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResultSet executeQuery(String sql) throws SQLException {
				execute(sql);
				if (resultSets.size() > 0) {
					return resultSets.get(0);
				} else {
					return new GenericResultSet();
				}
				
			}

			private List<GenericDataSourceColumnInfo> getColumnQueryDetails(String tableName, List<String> colNames) {
				List<GenericDataSourceColumnInfo> colDetails = new ArrayList<GenericDataSourceColumnInfo>();
				List<GenericDataSourceColumnInfo> allColumns = AGenericDataSource.this.getColumns(DatabaseUtils.getTableName(tableName));
				for (String colName : colNames) {
					for (GenericDataSourceColumnInfo col : allColumns) {
						if (col.getColumnName().equalsIgnoreCase(colName)) {
							GenericDataSourceColumnInfo colDetail = col.clone();
							colDetails.add(colDetail);
						}
					}
				}
				return colDetails;
			}
			
			@Override
			public int executeUpdate(String sql) throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int executeUpdate(String sql, int autoGeneratedKeys)
					throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int executeUpdate(String sql, int[] columnIndexes)
					throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int executeUpdate(String sql, String[] columnNames)
					throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public Connection getConnection() throws SQLException {
				return sqlConnection;
			}

			@Override
			public int getFetchDirection() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getFetchSize() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public ResultSet getGeneratedKeys() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public int getMaxFieldSize() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getMaxRows() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public boolean getMoreResults() throws SQLException {
				return getMoreResults(Statement.CLOSE_CURRENT_RESULT);
			}

			@Override
			public boolean getMoreResults(int current) throws SQLException {
				if(curResultSet < resultSets.size()) {
					if (current == Statement.CLOSE_CURRENT_RESULT) {
						resultSets.get(curResultSet).close();
					} else if (current == Statement.CLOSE_ALL_RESULTS) {
						for (int i=0; i <= curResultSet; i++) {
							resultSets.get(i).close();
						}
					}
					curResultSet++;
					if (curResultSet < resultSets.size()) {
						return true;
					} else {
						return false;
					}
				} else {
					return false;
				}
			}

			@Override
			public int getQueryTimeout() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public ResultSet getResultSet() throws SQLException {
				if (resultSets.size() > 0) {
					if (curResultSet < resultSets.size()) {
						return resultSets.get(curResultSet);
					} else {
						return null;
					}
				} else {
					return null;
				}
			}

			@Override
			public int getResultSetConcurrency() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getResultSetHoldability() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getResultSetType() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public int getUpdateCount() throws SQLException {
				// TODO Auto-generated method stub
				return 0;
			}

			@Override
			public SQLWarning getWarnings() throws SQLException {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void setCursorName(String name) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void setEscapeProcessing(boolean enable) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void setFetchDirection(int direction) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void setFetchSize(int rows) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void setMaxFieldSize(int max) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void setMaxRows(int max) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void setQueryTimeout(int seconds) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public boolean isClosed() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}

			@Override
			public void setPoolable(boolean poolable) throws SQLException {
				// TODO Auto-generated method stub
				
			}

			@Override
			public boolean isPoolable() throws SQLException {
				// TODO Auto-generated method stub
				return false;
			}
			
		}
	}
}
